public class Date {
    //这些变量属于对象
    public int year;
    public int month;
    public int day;

/*    public Date(int year, int month, int day){
        this.year = 2024;
        this.month =3;
        this.day = 31;
        System.out.println("学Java！");
    }*/


/*    public Date(int month) {
        this.month = month;
    }
    public Date(int year, int month) {
        this.year = year;
        this.month = month;
    }*/
    public Date(){
        this(2024,3,31);//必须放在第一行
        System.out.println("22222222");
    }

    public Date(int year, int month, int day) {
//        this();//error
        this.year = year;
        this.month = month;
        this.day = day;
        System.out.println("11111111");
    }



    //设置日期
    public void setDate(int year,int month,int day){
        this.year=year;//局部变量优先使用
        this.month=month;//在括号里面自己调用自己，修改的是局部变量，出了括号后，又变为了0
        this.day=day;
    }
    //打印日期
    public void printDate(){
        System.out.println(this.year+" 年 "+this.month+" 月 "+this.day+" 日 ");
    }

    public static void main(String[] args) {
        Date date=new Date();
        date.printDate();
    }

/*    public static void main1(String[] args) {
        Date date=new Date();//new一个对象date
        date.setDate(2024,3,31);
        date.printDate();
        System.out.println("**********");
        Date date2=new Date();//new一个对象date
        date2.setDate(2024,3,30);
        date2.printDate();

    }*/
}
